package com.rui.shangXueTang.huffman;

/**
 * @author : [锐神NO.3]
 * @version : [v1.0]
 * @className : NodeCode
 * @createTime : [2022/2/17 22:46]
 * @description : [描述该类的功能]
 */

public class NodeCode implements Comparable<NodeCode> {

    public Byte data;

    public int weight;

    public NodeCode left;

    public NodeCode right;

    public NodeCode(int weight) {
        this.weight = weight;
    }

    public NodeCode() {
    }

    public NodeCode(Byte data, int weight) {
        this.data = data;
        this.weight = weight;
    }

    @Override
    public int compareTo(NodeCode o) {
        return 0;
    }

    @Override
    public String toString() {
        return "NodeCode{" +
                "data=" + data +
                ", weight=" + weight +
                '}';
    }

    /**
     * 前序遍历
     */
    public void preSelect() {
        System.out.println(this);

        if(this.left != null){
            this.left.preSelect();
        }

        if(this.right != null){
            this.right.preSelect();
        }
    }
}
